package com.lian.chatroom.server.service;

import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 用户都写死在内存中
 */
@Service
public class UserServiceMemoryImpl implements UserService {

    //最定义map，用来存储用户账户密码
    private Map<String,String> allUserMap = new ConcurrentHashMap<>();

    {
        allUserMap.put("zhangsan","123");
        allUserMap.put("lisi","123");
        allUserMap.put("wangwu","123");
        allUserMap.put("mazi","123");
    }

    @Override
    public Boolean login(String username, String password) {
        String pwd = allUserMap.get(username);
        if (pwd == null){
            return false;
        }
        return pwd.equals(password);
    }
}
